package com.example.eurekac.service.impl;

import com.example.eurekac.entity.City;
import com.example.eurekac.entity.PageBean;
import com.example.eurekac.entity.User;
import com.example.eurekac.mapper.UserMapper;
import com.example.eurekac.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: config-client
 * @description: user
 * @author: ZhouGuoFeng
 * @create: 2018-09-21 15:29
 **/
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    UserMapper userMapper;
    @Override
    public User selectByPrimaryKey(String password) {
        return userMapper.selectByPrimaryKey(password);
    }

    /**
     * 密码加密
     * @param password
     */
    @Override
    public void insertPassWord(User password) {
        userMapper.insertPassWord(password);
    }

    @Override
    public String id() {
        return userMapper.id();
    }

    @Override
    public List<City> getCity(City city) {
        return userMapper.getCity(city);
    }

    @Override
    public List<User> findAllUserMsg() {
        return userMapper.findAllUserMsg();
    }

    @Override
    public List<User> findUserMsg(PageBean pb) {
        return userMapper.findUserMsg(pb);
    }

    @Override
    public PageBean<User> findUserMsgwithPage(PageBean pb) {
        List<User> list=this.findAllUserMsg();
        //总条数
        int total=list.size();
        //
        PageBean p=new PageBean(pb.getPageNum(),pb.getPageSize(),total);
        //获取开始标识
        int start=p.getStartIndex();
        pb.setStartIndex(start);
        //获取分页数据
        List<User> data=this.findUserMsg(pb);
        p.setList(data);
        return p;
    }
}
